package com.easidea.tim.flex.remote.finance
{
	import com.easidea.tim.flex.Env;
	import com.easidea.tim.flex.event.CustomerEvent;
	import com.easidea.tim.flex.remote.BaseDao;
	
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	
	import net.digitalprimates.persistence.hibernate.rpc.HibernateRemoteObject;

	public class AccountAgeReportDao extends BaseDao
	{
		private var _accountAgeReportService:HibernateRemoteObject = new HibernateRemoteObject();
		private static var _instance:AccountAgeReportDao;
		
		public static function getInstance():AccountAgeReportDao{
			if( !_instance ){
				_instance = new AccountAgeReportDao();
				
			}
			return _instance;
		}
		
		public function AccountAgeReportDao() {
				_accountAgeReportService.channelSet = this.buildChannelSet();
				_accountAgeReportService.destination="accountAgeReportService";	
				_accountAgeReportService.concurrency = "last";
				_accountAgeReportService.makeObjectsBindable = true;	
				_accountAgeReportService.showBusyCursor = true;
		}
		
		
		
		public function getReport(staffName:String, custName:String):void{
			_accountAgeReportService.addEventListener(ResultEvent.RESULT, getReportResult);
			_accountAgeReportService.addEventListener(FaultEvent.FAULT,_Fault);
			_accountAgeReportService.queryList(custName, staffName);
		}
		
		private function getReportResult(e:ResultEvent):void {
			_accountAgeReportService.removeEventListener(ResultEvent.RESULT, getReportResult);
			Env.dispatchEvent(new CustomerEvent("getReportSuccess",e.result));
		}
	}
}